<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
</head>
<body>
<form id="form" class="layui-form-pane layui-form">
    <input type="hidden" id="userId" name="userId" th:value="${user.getUserId()}">
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">用户名：</label>
        <div class="layui-input-block">
            <input class="layui-input" id="userName" name="userName" th:value="${user.getUserName()}" autocomplete="off"/>
        </div>
    </div>
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">密码：</label>
        <div class="layui-input-block">
            <input class="layui-input" id="userPass" name="userPass" th:value="${user.getUserPass()}" autocomplete="off"/>
        </div>
    </div>
    <br/>
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">昵名：</label>
        <div class="layui-input-block">
            <input class="layui-input" id="userAccount" name="userAccount" th:value="${user.getUserAccount()}" autocomplete="off"/>
        </div>
    </div>
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">邮箱：</label>
        <div class="layui-input-block">
            <input type="email" class="layui-input" id="userEmail" name="userEmail" th:value="${user.getUserEmail()}" autocomplete="off"/>
        </div>
    </div>
    <br/>
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">电话：</label>
        <div class="layui-input-block">
            <input class="layui-input" id="userIphone" name="userIphone" th:value="${user.getUserIphone()}" autocomplete="off"/>
        </div>
    </div>
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-block" style="width: 185px">
            <select id="status" name="status" class="layui-select"  lay-verify="required" lay-search="">
                <option value="正常" th:selected="${user.getStatus() == '正常'}">正常</option>
                <option value="注销" th:selected="${user.getStatus() == '注销'}">注销</option>
            </select>
        </div>
    </div>
    <br/>
    <div class="layui-form-item">
        <label class="layui-form-label">角色：</label>
        <div class="layui-input-block">
            <input type="checkbox" th:each="role:${roles}" name="rids" th:value="${role.getRoleId()}" th:title="${role.getRname()}" th:checked="${#lists.contains(checked,role.getRoleId()+'')}">
        </div>
    </div>
    <br/>
    <div class="layui-form-item layui-inline" style="float: right; margin-right: 10px;">
        <button class="layui-btn" id="updateUser">提交</button>
        <button class="layui-btn layui-btn-danger" onclick="closePage()">关闭</button>
    </div>
</form>

</body>
<script th:src="@{/layui/layui.js}"></script>
<script th:src="@{/js/jquery-2.1.0.js}"></script>
<script>
    var index = parent.layer.getFrameIndex(window.name);
    layui.use('form',function(){
        var form = layui.form;
        form.render();
    });
    layui.use('layer',function(){
        var layer=layui.layer;
    });
    function closePage() {
        parent.layer.close(index);//关闭当前页
    }

    $('#updateUser').click(function(){

        $.ajax({
            type:'post',
            url:'/user/updateUser',
            data:$("#form").serialize(),
            dataType: "text",
            async: false,
            success:function (data) {

                if (data === 1){
                }
            }
        });

        window.parent.location.reload();//刷新父页面
        parent.layer.close(index);
    });

</script>
</html>